package com.gsname.java.base.demo;

public class Student {

	public String name;

	/**
	 * 私有化
	 */
	private String stuNo;

	/**
	 * age>0,age<200
	 */
	private int age;

	/**
	 * "男","女"
	 */
	private String sex;

	public int getAge() {
		return age;
	}

	/**
	 * 安全检查
	 * 
	 * @param age
	 */
	public void setAge(int age) {
		if (age < 0) {
			age = 1;
		}else if (age >= 200) {
			age = 200;
		}else{
			this.age = 0;
		}
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	/**
	 * 
	 * @param sex
	 */
	public void setSex(String sex) {
		if ("男".equals(sex) || "女".equals(sex)) {
			this.sex = sex;
		}else{
			this.sex = "Nin";
		}
	}

	// 驼峰命名法
	/**
	 * getter方法
	 * 
	 * @return
	 */
	public String getStuNo() {
		return this.stuNo;
	}

	/**
	 * setter方法
	 * 
	 * @param stuNo
	 */
	public void setStuNo(String stuNo) {
		this.stuNo = stuNo;
	}

}
